/**自定义模块*/
layui.define(['layer','jquery'], function (exports) {
    var $ = layui.jquery,
        layer = layui.layer;
    var XmCommon = {

        /**错误msg提示 */
        xmLayErrorMsg:function (text) {
            top.layer.msg(text, {icon: 5});
        },
        /**成功 msg提示 */
        xmLaySucMsg:function (text) {
            top.layer.msg(text, {icon: 6});
        },
        /**ajax Confirm 对话框*/
        ajaxXmConfirm: function (title, text, url,param) {
            layer.confirm(text, {
                title: title,
                resize: false,
                btn: ['确定', '取消'],
                btnAlign: 'c',
                anim:1,
                icon: 3
            }, function () {
                $.ajax({
                    url : url,
                    type : 'post',
                    async: false,
                    data : param,
                    success : function(data) {
                        if(data.code == 0){
                            top.layer.msg(data.message, {icon: 6});
                            location.reload();
                        }else{
                            if(data.data.jump_url!=""){
                                var jump_url = data.data.jump_url;
                                top.layer.msg(data.message,{icon: 5},function(){
                                    document.location.href=jump_url;
                                });
                            }else{
                                top.layer.msg(data.message,{icon: 5});
                            }

                        }
                    },error:function(data){

                    }
                });

            }, function () {

            })

        },
        /**弹出层*/
        xmLayOpen:function (title,url,width,height) {

            var index = layui.layer.open({
                title : '<i class="larry-icon larry-bianji3"></i>'+title,
                type : 2,
                skin : 'layui-layer-molv',
                content : url,
                area: [width, height],
                resize:false,
                anim:1,
                success : function(layero, index){

                }
            });
        },
        /**弹出层-tip*/
        xmLayOpenTip:function (title,url,width,height) {

            var index = layui.layer.open({
                title : '<i class="larry-icon larry-bianji3"></i>'+title,
                type : 2,
                skin : 'layui-layer-molv',
                content : url,
                area: [width, height],
                resize:false,
                anim:1,
                success : function(layero, index){
                    setTimeout(function(){
                        layui.layer.tips('点击此处返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: [3, '#009f95']
                        });
                    },500)

                }
            });
        },
        /**退出*/
        logOut: function (title, text, url) {
            parent.layer.confirm(text, {
                title: title,
                resize: false,
                btn: ['确定退出系统', '不，我点错了！'],
                btnAlign: 'c',
                icon: 3
            }, function () {
                $.ajax({
                    url:url,
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        document.location.href = res.data.jump_url;
                    }
                })
            }, function () {
               
            })
        },
        /**重置表格宽度*/
        resizeGrid:function (){
            $(".layui-table-view .layui-table").css("width", "100%");
            $(window).resize(function(){
                $(".layui-table-view .layui-table").css("width", "100%");

            });
        }
    };
    exports('common', XmCommon)
})



